<?
function getHTMLSearch($title,$ceibal,$dat,$items_per_row, $ceibal_page, $xos_page){
?>

	<div class="titulo_busq" style="width:100%;">
		<span><?= $title ?></span>
		<div class="pager_busq">
			<?
			if ($dat["page"] > 1) {
				$ant_page = $dat["page"] - 1;
			?>
				<img src="<?= base_url(); ?>images/pager/prev.png" title="Anterior" onclick="buscarCanales2(<?= $caibal ? "$xos_page,$ant_page":"$ant_page,$ceibal_page"; ?>);">
			<?
			}
			if ($dat["page"] < $dat["cant_pages"]) {
				$next_page = $dat["page"] + 1;
			?>
				<img src="<?= base_url(); ?>images/pager/next.png" title="Pr&oacute;ximo" onclick="buscarCanales2(<?= $caibal ? "$xos_page,$next_page":"$next_page,$ceibal_page"; ?>);">
            <? }?>
		</div>
	</div>
	<div style="height:100%;padding: 1em;<?= $ceibal ? "background-color: #044040;":"" ?>">
		<table>
			<tr class="ul_busq">
				<?
				$items_in_row=$items_per_row;
				foreach ($dat["channels"] as $index => $channel) {
					$channel_id = $channel->id;
					$channel_name = $channel->name;
					$channel_description = $channel->description;
					$csource = "'$channel_id','$channel_name','$channel_description'";
                                        $thumb_src = $channel->thumb == NULL ? (base_url() . "images/goalbit.jpg"):("data:image/png;base64,".$channel->thumb);

					if (($index % $items_per_row) == 0 && $index > 0) {
						$items_in_row = $items_per_row;
						echo "</tr><tr class='ul_busq'>";
					}
					$items_in_row--;
				?>
					<td valign="top">
						<div class="ul_item ui-corner-all" onclick="setChannelSource(<?= $csource ?>);" title="Ver el canal">
							<img src="<?= $thumb_src ?>" alt="Logo del canal">
							<span><?= $channel_name ?></span>
						</div>
					</td>
			<?	}
				for($index=$items_in_row;$index>0;$index--){
			?>
					<td>
						<div class="ul_item ui-corner-all">
							&nbsp;
						</div>
					</td>
			<?	}
			?>

			</tr>
		</table>
	</div>

<?
}
?>

<div style="display: inline-block;height:100%;">
	<? getHTMLSearch("Canales Ceibal",true,$ceibal_data,2, $ceibal_data["page"], $data["page"]);?>
</div>
<div  style="display: inline-block;height:100%;margin-left: -5px;">
	<? getHTMLSearch("XOs",false,$data,4, $ceibal_data["page"], $data["page"]);?>
</div>
